package Entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Temporal;

@Entity 
@Inheritance (strategy=InheritanceType.JOINED) //definig the mapping strategy
public class Person implements Serializable {    // father class
    
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO) //create prymary key id
    @Column (name = "PersonID")                   //id will be mapped into a column named PersonId  
    private Long id;    
    @Column(nullable = false)
    private String name;
    @Column(nullable = false)
    private String lastname;
    @Column(nullable = false)
    private String SSN;                           //social security number
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date birthday;
    @Column(nullable = false)
    private String birthplace;
    
    //CONSTRUCTOR WITH PARAMS 
    public Person(String name, String lastname, String SSN, Date bithdate, String birthplace) {
        this.name = name;
        this.lastname = lastname;
        this.SSN = SSN;
        this.birthday = bithdate;
        this.birthplace = birthplace;
    }
    //CONSTRUCTOR NULL
    public Person(){
        super();
        this.name = "NN";
        this.lastname = "NN";
        this.SSN = "000-00-000";
        this.birthday = null;
        this.birthplace = "No Place";
    }
   
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    public String getName(){
    return name;
    }
    
    public void setName(String name){
    this.name = name;
    }
    
    @Override
    public String toString(){
        return "NAME: "+name+"  LASTNAME: "+lastname+"  SSN: "+SSN+"\n";
    }
}
